/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GestionarCampaNaPublicitariaUI.java
 *
 * Created on 10/06/2009, 09:30:04 PM
 */

package CRM_UI;

import DAO.DAOCampaNaArticulo;
import DAO.DAOCampanaPublicitaria;
import DAO.DAOEmpleadoCampana;
import DAO.DAOMediosPublicitarios;
import LogicaNegocio.CampanaPublicitaria;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author LÂ¡z
 */
public class GestionarCampaNaPublicitariaUI extends javax.swing.JFrame {

    Vector <Vector> campanaTabla; //filas de tabla
    Vector <String> nombreColumnas; //columnas de la tabla
    String idSeleccionado;

    public GestionarCampaNaPublicitariaUI()
    {
        campanaTabla= new Vector<Vector>();

        //clave
        inicializarColumnas();
        consultarCampana();
        initComponents();
        tablaCampaNa.setModel(new DefaultTableModel(campanaTabla, nombreColumnas));
        //setLocationRelativeTo(null);
    }

    public void inicializarColumnas()
    {
        nombreColumnas= new Vector<String>();
        nombreColumnas.addElement("Codigo");
        nombreColumnas.addElement("Nombre");
        nombreColumnas.addElement("DescripciÃ³n");
        //nombreColumnas.addElement("Medios Publicitarios");
        nombreColumnas.addElement("Presupuesto");
        //nombreColumnas.addElement("Articulos");
        //nombreColumnas.addElement("Fecha ASignacion Articulos");
        //nombreColumnas.addElement("Mercaderistas");
        
    }




    public void consultarCampana()
    {
        DAOCampanaPublicitaria daoCampana= new DAOCampanaPublicitaria();
        Vector<CampanaPublicitaria> vectorCampana= new Vector<CampanaPublicitaria>();
        vectorCampana = daoCampana.consultarCampanas();

        System.out.println(vectorCampana.size());

        for(int i=0; i<vectorCampana.size(); i++)
        {
            Vector campana= new Vector() ; //cada fila o tupla de la tabla
            campana.addElement(vectorCampana.elementAt(i).getCodigoCampana());
            campana.addElement(vectorCampana.elementAt(i).getNombreCampana());
            campana.addElement(vectorCampana.elementAt(i).getDescripcionCampana());
            //campana.addElement(vectorCampana.elementAt(i).getMedioPublicitario());
            campana.addElement(vectorCampana.elementAt(i).getPresupuestoCampana());
            //campana.addElement(vectorCampana.elementAt(i).getArticulo());
            //campana.addElement(vectorCampana.elementAt(i).getFechaAsigArticulos());
            //campana.addElement(vectorCampana.elementAt(i).getMercaderista());            
            campanaTabla.addElement(campana);
        }

    }

    public void ActualizarTabla()
    {
        tablaCampaNa.setModel(new DefaultTableModel(campanaTabla, nombreColumnas));
    }



    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaCampaNa = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        texFieldCodigo = new javax.swing.JTextField();
        textFieldNombre = new javax.swing.JTextField();
        textFielMP1 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        textFieldPresu = new javax.swing.JTextField();
        textFielMP2 = new javax.swing.JTextField();
        textFielMP3 = new javax.swing.JTextField();
        jScrollPane3 = new javax.swing.JScrollPane();
        textAreaDescripcion = new javax.swing.JTextArea();
        textFielMP4 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        textFlieldA1 = new javax.swing.JTextField();
        textFlieldA2 = new javax.swing.JTextField();
        textFlieldA3 = new javax.swing.JTextField();
        textFlieldA4 = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        textFieldFechaAs = new javax.swing.JTextField();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Campaña Publicitaria"));

        /*
        tablaCampaNa.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Codigo", "Nombre", "Descripción", "Medios Publicitarios", "Presupuesto"
            }
        ));
        */
        jScrollPane1.setViewportView(tablaCampaNa);

        jScrollPane2.setViewportView(jScrollPane1);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 469, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Modificar"));

        jLabel1.setText("Codigo:");

        jLabel2.setText("Nombre:");

        jLabel3.setText("Descripción:");

        jLabel4.setText("Presupuesto:");

        texFieldCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                texFieldCodigoActionPerformed(evt);
            }
        });

        textFielMP1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFielMP1ActionPerformed(evt);
            }
        });

        jLabel5.setText("Medios Publicitarios:");

        textFieldPresu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFieldPresuActionPerformed(evt);
            }
        });

        textAreaDescripcion.setColumns(20);
        textAreaDescripcion.setRows(5);
        jScrollPane3.setViewportView(textAreaDescripcion);

        jLabel6.setText("Articulos");

        textFlieldA1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFlieldA1ActionPerformed(evt);
            }
        });

        jLabel7.setText("Fecha de asignación");

        textFieldFechaAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFieldFechaAsActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel5))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel4))
                                .addGap(37, 37, 37)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(texFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(textFieldNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(textFieldPresu, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addGroup(jPanel2Layout.createSequentialGroup()
                                                .addComponent(textFielMP1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(textFielMP2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(textFielMP3, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel2Layout.createSequentialGroup()
                                                .addComponent(textFlieldA1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(textFlieldA2)
                                                .addGap(18, 18, 18)
                                                .addComponent(textFlieldA3, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(22, 22, 22)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(textFlieldA4)
                                            .addComponent(textFielMP4, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)))))
                            .addComponent(jLabel3)
                            .addComponent(jLabel6)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(textFieldFechaAs, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(117, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(texFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textFieldNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(81, 81, 81))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(textFielMP1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textFielMP2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textFielMP3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textFielMP4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textFieldPresu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(30, 30, 30)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel6)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(textFlieldA1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(textFlieldA2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(textFlieldA4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(textFlieldA3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(textFieldFechaAs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(71, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botonEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonEliminarActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_botonEliminarActionPerformed

    private void botonCrearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonCrearActionPerformed
        DAOCampanaPublicitaria daoCampana= new DAOCampanaPublicitaria();
        DAOMediosPublicitarios daoMedio= new DAOMediosPublicitarios();
        DAOEmpleadoCampana daoEmpleadoCampana= new DAOEmpleadoCampana();
        DAOCampaNaArticulo daoCampanaArticulo= new DAOCampaNaArticulo();

        CampanaPublicitaria campana= new CampanaPublicitaria(texFieldCodigo.getText(), textFieldNombre.getText(), textAreaDescripcion.getText(), Integer.parseInt(textFieldPresu.getText()));
        campana.setMedioPublicitario(textFielMP1.getText());
        campana.setMedioPublicitario(textFielMP2.getText());
        campana.setMedioPublicitario(textFielMP3.getText());
        campana.setMedioPublicitario(textFielMP4.getText());

       

        campana.setArticulo(textFlieldA1.getText());
        campana.setArticulo(textFlieldA2.getText());
        campana.setArticulo(textFlieldA3.getText());
        campana.setArticulo(textFlieldA4.getText());

        int i=0;
         int j=0;
         int m=0;
         int n=0;
         i=daoCampana.guardarCamapanaPublictaria(campana);
         Vector<String> vector= campana.getMedioPublicitario();
         Vector<String> vectorMercaderistas= campana.getMercaderista();
         Vector<String> vectorArticulos= campana.getArticulo();

         for(int k=0; k<vector.size(); k++)
         {
            System.out.println(vector.elementAt(k));
            if(!vector.elementAt(k).equals(""))
            {
                j=daoMedio.guardarMediosPublicitarios(vector.elementAt(k), campana.getCodigoCampana());
            }
         }

         for(int l=0; l<vectorMercaderistas.size(); l++)
         {
            System.out.println(vectorMercaderistas.elementAt(l));

            if(!vectorMercaderistas.elementAt(l).equals(""))
            {
                m=daoEmpleadoCampana.guardarEmpleadoCampana(vectorMercaderistas.elementAt(l), campana.getCodigoCampana());
            }
         }

         for(int a=0; a<vectorArticulos.size(); a++)
         {
            System.out.println(vectorArticulos.elementAt(a));

            if(!vectorArticulos.elementAt(a).equals(""))
            {
                n=daoCampanaArticulo.guardaCampanaArticulo(campana.getCodigoCampana(), vectorArticulos.elementAt(a), textFieldFechaAs.getText());
            }
         }


        //CampanaPublicitaria campana= new CampanaPublicitaria("CP005", "Campana5", "Campana por fiestas de fin de aÃ±o", 2450000);

        System.out.print("Se han insertado " + i + " campana " + j + " medio "+ m + " mercaderistas " + n +" articulos a la BD\n" );
        consultarCampana();
        ActualizarTabla();




}//GEN-LAST:event_botonCrearActionPerformed

    private void texFieldCodigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_texFieldCodigoActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_texFieldCodigoActionPerformed

    private void textFieldPresuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFieldPresuActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_textFieldPresuActionPerformed

    private void textFielMP1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFielMP1ActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_textFielMP1ActionPerformed

    private void textFieldM2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFieldM2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textFieldM2ActionPerformed

    private void tablaCampaNaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaCampanaMouseClicked
        int fila = tablaCampaNa.getSelectedRow();
        idSeleccionado = tablaCampaNa.getValueAt(fila, 0).toString();
        texFieldCodigo.setText(idSeleccionado);
        textFieldNombre.setText(tablaCampaNa.getValueAt(fila,1).toString());
        textAreaDescripcion.setText(tablaCampaNa.getValueAt(fila,2).toString());
        textFieldPresu.setText(tablaCampaNa.getValueAt(fila,3).toString());
}//GEN-LAST:event_tablaCampanaMouseClicked

    private void textFlieldA1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFlieldA1ActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_textFlieldA1ActionPerformed

    private void textFieldFechaAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFieldFechaAsActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_textFieldFechaAsActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonModificarActionPerformed
        DAOCampanaPublicitaria daoCampana= new DAOCampanaPublicitaria();
        DAOMediosPublicitarios daoMedio= new DAOMediosPublicitarios();
        DAOEmpleadoCampana daoEmpleadoCampana= new DAOEmpleadoCampana();
        DAOCampaNaArticulo daoCampanaArticulo= new DAOCampaNaArticulo();

        CampanaPublicitaria campana= new CampanaPublicitaria(texFieldCodigo.getText(), textFieldNombre.getText(), textAreaDescripcion.getText(), Integer.parseInt(textFieldPresu.getText()));
        campana.setMedioPublicitario(textFielMP1.getText());
        campana.setMedioPublicitario(textFielMP2.getText());
        campana.setMedioPublicitario(textFielMP3.getText());




        campana.setArticulo(textFlieldA1.getText());
        campana.setArticulo(textFlieldA2.getText());
        campana.setArticulo(textFlieldA3.getText());
        campana.setArticulo(textFlieldA4.getText());


        int i= daoCampana.modificarNombreCampana(campana);
        daoCampana.modificarDescripcionCampana(campana);
        daoCampana.modificarPresupuestoCampana(campana);


        int j= daoMedio.modificarMediosPublicitarios(campana.getNombreCampana(), idSeleccionado);



        System.out.print("Se han modificado " + i + " producto"+" y "+ j+" articulo "+" en la BD\n");
        System.exit(0);
        consultarCampana();
}//GEN-LAST:event_botonModificarActionPerformed

   
    /*
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new GestionarCampaNaPublicitariaUI().setVisible(true);
            }
        });
    }*/

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable tablaCampaNa;
    private javax.swing.JTextField texFieldCodigo;
    private javax.swing.JTextArea textAreaDescripcion;
    private javax.swing.JTextField textFielMP1;
    private javax.swing.JTextField textFielMP2;
    private javax.swing.JTextField textFielMP3;
    private javax.swing.JTextField textFielMP4;
    private javax.swing.JTextField textFieldFechaAs;
    private javax.swing.JTextField textFieldNombre;
    private javax.swing.JTextField textFieldPresu;
    private javax.swing.JTextField textFlieldA1;
    private javax.swing.JTextField textFlieldA2;
    private javax.swing.JTextField textFlieldA3;
    private javax.swing.JTextField textFlieldA4;
    // End of variables declaration//GEN-END:variables

}
